package cricket;

import java.util.HashMap;

public class CricketPlayer {
	
	private String name;
	private HashMap<Integer, Integer> scores = new HashMap<Integer, Integer>();
	
	public String getName() {
		return name;
	}

	private int score;
	
	public CricketPlayer (String name) {
		this.name = name;
		score = 0;
		for (int i = 0; i < CricketGame.targets.length; i++) {
			scores.put(CricketGame.targets[i], 0);
		}
	}
	
	public void addToScore (int newScore) {
		score += newScore;
	}
	
	public void hit(Integer number, boolean canScore) {
		Integer i = scores.get(number);
		i += 1;
		if (i > 3 && canScore) {
			score += number;
		}
		scores.put(number, i);
	}
	
	public int getScore() {
		return score;
	}
	
	public HashMap<Integer, Integer> getScores() {
		return scores;
	}
}
